#!/bin/sh
# 把 git hooks 复制到 .git 目录中

git_dir="../.git";

if [[ ! -d "$git_dir" ]]; then
    echo "You should run this shell in Git Repo root directory"
    exit 1
fi

cd "$git_dir"

if [[ -d "./hooks" ]]; then
    if [[ -d "./hooks.bu"  ]]; then
        rm -rf ./hooks
        echo "update git hooks..."
    else
        echo "back up your origin hooks to hook.bu"
        mv "./hooks" "./hooks.bu"
    fi
    rm -rf "hooks"
    cp -r "../dw-lara/git-hooks" "./"
    mv git-hooks hooks
    chmod +x ./hooks/*
fi

exit 0
